// vite.config.ts
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { NaiveUiResolver } from "unplugin-vue-components/resolvers";
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
import { resolve } from "path";
import path from "path";
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      imports: [
        "vue",
        {
          "naive-ui": [
            "useDialog",
            "useMessage",
            "useNotification",
            "useLoadingBar",
          ],
        },
      ],
    }),
    Components({
      resolvers: [NaiveUiResolver()],
    }),
    createSvgIconsPlugin({
      // 指定需要缓存的图标文件夹
      // iconDirs: [resolve(pathSrc, "assets/icons")],
      // iconDirs: [resolve(__dirname, "src/assets/icons")],
      iconDirs: [resolve(process.cwd(), "src/assets/svg")], // 指定项目内图标路径
      // 指定symbolId格式
      symbolId: "icon-[dir]-[name]",
    }),
  ],
  base: "/editor/",
  resolve: {
    alias: [
      {
        find: "@",
        replacement: path.resolve(__dirname, "./src"),
      },
    ],
  },
  server: {
    host: "0.0.0.0",
    port: 5173,
  },
});
